<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>添加题库</title>
    <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
</head>

<body>
<br>
<br>
<br>
<br>
<br>
<center>
    <br>
    题库名称:<input id="name" type="text" /><br>
    <br>
    创建者id:<input id="userId" type="number" /><br>
    <br>
    创建时间:<input id="createTime" type="datetime-local" /><br>
    <br>
    <button onclick="add();">保存</button>
</center>
</body>

<script language="JavaScript" type="application/javascript">
    function add(){
        var name = $("#name").val();
        var userId = $("#userId").val();
        var createTime = $("#createTime").val();
        // 判断
        $.ajax({
            type: "post",
            url: "/repocontroller/addRepo",
            data: {
                "name":name,
                "userId": userId,
                "createTime": createTime
            },
            success: function (data){
                var code = JSON.parse(data);
                alert(code.code);
                if(code.code == "1"){
                    alert("保存成功")
                    location.href = "/repocontroller";
                } else {
                    alert("保存数据失败。");
                }
            }
        })
    }
</script>

</html>
